package com.tbit.uqbike.client.remote;

import com.tbit.uqbike.client.constant.GatewayProtocol;
import com.tbit.uqbike.client.constant.RabbitMQData;
import com.tbit.uqbike.client.constant.SystemData;
import com.tbit.uqbike.client.constant.UseTimeConstant;
import com.tbit.uqbike.client.pojo.ComsumTime;
import com.tbit.uqbike.client.pojo.Machine;
import com.tbit.uqbike.client.pojo.MqData;
import com.tbit.uqbike.client.util.DateTimeUtil;

import java.util.Date;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 9:05 2021/4/22
 */
public class DataUtils {

    public static void addFind(Machine machine, Integer userId, Integer parkPointId, String addTime, String software, String appWare, String phoneType, String way, Integer orderSource) {
        /**找车时长逻辑处理,放入mq*/
        Date endTime = new Date();
        ComsumTime comsumTime = new ComsumTime();
        comsumTime.setAccountId(machine.getAccountId());
        comsumTime.setEndTime(endTime);
        comsumTime.setMachineNO(machine.getMachineNO());
        comsumTime.setOrderSource(orderSource);
        comsumTime.setStartTime(DateTimeUtil.StringToDateTime(addTime));
        comsumTime.setTime(DateTimeUtil.getTimeDF(addTime, DateTimeUtil.DateTimeToString(endTime)));
        comsumTime.setUserCode(machine.getUserCode());
        comsumTime.setType(UseTimeConstant.USE_TIME_INTERNET);
        comsumTime.setUserId(userId);
        comsumTime.setOperateType(UseTimeConstant.OPEATE_FIND);
      /*String software = request.getHeader("software");
      String appWare = request.getHeader("appWare");
      String phoneType = request.getHeader("phoneType");
      String way = request.getHeader("way");*/
        if (software != null) {
            comsumTime.setSoftware(software);
        }
        if (appWare != null) {
            comsumTime.setAppWare(appWare);
        }
        if (phoneType != null) {
            comsumTime.setPhoneType(phoneType);
        }
        if (way != null) {
            comsumTime.setWay("");
        }
      /*Integer parkPointId=null;
      ParkMachine parkMachine = parkMachineService.getByMachineId(machine.getMachineId());
      if(parkMachine!=null){
        parkPointId=parkMachine.getParkPointId();
      }*/
        comsumTime.setParkPointId(parkPointId);
        MqData mqData = new MqData();
        mqData.setMsgId(GatewayProtocol.MQ_MSG_ID_AROUND_TIME_PUSH);
        mqData.setFeedback(RabbitMQData.aiQueue);
        mqData.setData(comsumTime);
        SystemData.pushList.add(mqData);

    }
}
